<template>
  <view>
    <view class="boyForm" v-if="isCoum.auditStatus == 99">
      <u--form labelPosition="left" :model="userInfo" :rules="rules" ref="uForm">
        <u-form-item label="手机号码" prop="phone" borderBottom ref="item1">
          <u--input placeholder="请输入手机号码" v-model="userInfo.phone" border="surround" maxlength='11'></u--input>
        </u-form-item>
        <u-form-item label="消费金额" prop="cost" borderBottom ref="item1">
          <u--input placeholder="10000 == 1积分" v-model="userInfo.cost" border="surround"></u--input>
        </u-form-item>
        <u-form-item>
          <u-button text="添加" @click="addIntegral" type="primary"></u-button>
        </u-form-item>
      </u--form>
    </view>
    <view class="title">积分详情</view>
    <view class="chat-container">
		<view class="tetLhei">
			<view>日期</view>
			<view>电话</view>
			<view>积分添加</view>	
		</view>
      <scroll-view :scroll-top="scrollTop" scroll-y="true" class="scroll-Y"  @scrolltolower="lower"
        >
        <view v-for="(item,index) in tabList" :key="index">
            <view class="tetLhei">
				<view>{{ item.updateTime}}</view>
				<view>{{ item.phone}}</view>
				<view>{{ item.changeScore }}</view>	
            </view>
        </view>
		<!-- <view v-for="(item,index) in tabList" :key="index">
		    <view class="tetLhei">
				<view class="lerthy">
					<view>积分添加：{{ item.changeScore }}</view>
				</view>
				<view class="jjjk">		
				<view>日期：{{ item.updateTime}}</view>
				<view>电话：{{ item.phone}}</view>
				</view>
				
		    </view>
		</view> -->

      </scroll-view>
    </view>
    <!-- <view @tap="goTop" class="uni-link uni-center uni-common-mt">
      点击这里返回顶部
    </view> -->
  </view>
</template>

<script>
import { addScore,pageList,sysUserName } from "@/api/index";
export default {
  data() {
    return {
      userInfo: {
        phone: "",
        cost: "",
      },
      rules: {
        phone: {
          type: "string",
          required: true,
          message: "请填写手机号码",
          trigger: ["blur", "change"],
        },
        cost: {
          type: "string",
          required: true,
          message: "请填写积分",
          trigger: ["blur", "change"],
        },
      },
      tabList:[],
      scrollTop:0,
      pageSwp:{
        page:1,
        pageSize:10
      },
	  isCoum:'',
    };
	
  },
  onShow() {
	  this.sysUserName()
  	this.pageList()
  },
  methods: {
    /**添加 */
    addIntegral() {
      this.$refs.uForm
        .validate()
        .then((res) => {
          addScore(this.userInfo).then((res) => {
            if (res.code == 0) {
              uni.showToast({
                title: "添加成功",
                icon: "none",
                duration: 2000,
              });
			  this.userInfo.phone=""
			  this.userInfo.cost=""
              this.pageList()
            } else {
              uni.showToast({
                title: res.msg,
                icon: "none",
                duration: 2000,
              });
            }
          });
        })
        .catch((errors) => {
          uni.$u.toast("请填写对应信息");
        });
    },
	sysUserName() {
	  sysUserName().then((res) => {
	    if (res.code == 0) {
	      this.isCoum = res.data
	    }
	  })
	},
    pageList(){
      pageList({
        current:this.pageSwp.page,
        size:this.pageSwp.pageSize
      }).then((res)=>{
        if (res.code == 0) {
          this.tabList = res.data.records
        }
      })
    },
    lower(){
      this.pageSwp.page ++
      this.pageList()
    }
  },
};
</script>

<style  lang="less" scoped>
.boyForm {
  padding: 0 21px;
  height: 200px;
  /deep/.u-form-item__body__left {
    width: 76px !important;
  }
}
.title{
  text-align: center;
  font-size: 24px;
  margin-bottom: 15px;
}
.scroll-Y{
  height: 70vh;
}
.tetLhei{
  height: 50px;
    display: flex;
    justify-content: space-between;
    margin: 11px;
    line-height: 50px;
    background-image: linear-gradient(to right, #f8f7fd 0%, #ebf9fc 100%);
    padding: 0 10px;
    border-radius: 12px;
}
</style>
